<?php
/**
 * PageView class
 * Generates XHTML page
 * functions to get XHTML, add meta tags and render tags into html
 */

class PageView {
	//Private variables to store metaTags and charset
  	private $m_metaTags = array();
  	private $m_charset;
	
	//Constructor, takes charset as parametar, if none given use UTF-8
	public function __construct($charset = "utf-8"){
		//set the charset var
		$this->m_charset = $charset;
	}
	
	//Public funtion to add stylesheets
	public function AddStyleSheet($href){
		//Store the link in our array
		$this->m_metaTags[] = "<link rel='StyleSheet' href='$href' type='text/css'";
	}
	
  /**
   * Builds meta and CSS tags as a HTML/XML string
   *    
   * @param bool $isXML is the document an XML file and tags should be closed 
   * @return string  
   */
 	private function BuildHeadTags($isXML) {
    		
		//Declare end-tag
    	if ($isXML) {
      		$end = "/>";
    	}
		else {
			$end = ">";
		}
		//Declare var to hold our headtags
    	$retValue = "";
		
		//Fill it with the tags in our array
    	foreach($this->m_metaTags as $tag) {
      		$retValue .= $tag . "$end\n            "; // "\n            " for readability
    	}
		
		//Return it
    	return $retValue;
  	}
	
	/**
	  * Returns a XHTML page
	  * @param string $title  
	  * @param string $body    
	  * @return string     
	  **/
	public function GetXHTML10StrictPage($title, $body, $menu, $skinlinksDiv) {
		$head = $this->BuildHeadTags(true);
		$xml = "<!DOCTYPE html>
				<html>
				<head>
				        
				    <!--  IE FIX  -->
					<script type='text/javascript'>
				        document.createElement('header');
				        document.createElement('hgroup');
				        document.createElement('nav');
				        document.createElement('menu');
				        document.createElement('section');
				        document.createElement('article');
				        document.createElement('aside');
				        document.createElement('footer');
				    </script>
				
				    <!-- Favicon -->
				    <link rel='shortcut icon' type='image/x-icon' href='favicon.png' />
				
				     <title>$title</title> 
				     <meta http-equiv=\"content-type\" content=\"text/html; charset=$this->m_charset\" /> 
				     
				     
				     $head
				</head> 
				<!--  Innehåll  -->
				<body>
				<section class='mainrapper'>
					<header>
						<section class='topBar'>
						</section>
						<nav class='headerNav'>
							<h1><strong><a href='?'>YAIC</a></strong></h1>
							<h2 class='yetanotherh2'>Yet Another Image Community</h2>
							$menu
							$skinlinksDiv
						</nav>
					</header>
						
					<section class='container'>
						$body
						
					</section>
		
					<footer>
						<section class='footerNav'>
							<h2>Interact with <strong>IMG-YAIC</strong></h2>
							
							<ul>
								<li><a href='#'><img alt='x' src='socialicon/Facebook.png' /></a></li>
								<li><a href='#'><img alt='x' src='socialicon/Twitter.png' /></a></li>
								<li><a href='#'><img alt='x' src='socialicon/Linkedin.png' /></a></li>
								<li><a href='#'><img alt='x' src='socialicon/Digg.png' /></a></li>
								<li><a href='#'><img alt='x' src='socialicon/Stumble.png' /></a></li>
							</ul>
							<h4>&copy; all rights reserved | 2011 | Note: This application requires JavaScript to be activated in your browser, we may all so use cookies to store information, dont like it? Dont enter!</h4>
							 
						</section>
							
					</footer>
					<!-- JS -->
					<script type='text/javascript' src='js/jquery.js'></script>
					<script type='text/javascript' src='js/easySlider.js'></script>
				    <script type='text/javascript' src='js/js.js' ></script>
				    <script type='text/javascript' src='js/validate.js' ></script>
			  	</section>  
				</body>
				</html>";
				
		return $xml;
	}
}